<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt"  uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <!--公共样式-->
    <link href="${pageContext.request.contextPath }/web/css/font/iconfont.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/web/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/web/css/NormalizeFile.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/web/css/public.css" />
    <!--列表页面私有样式-->
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/web/css/subpage/person.css" />
</head>
<body class="w928">
<!--用户中心 begin-->
    <!--个人信息-->
    <div class="right-content bor1">
        <div class="bor1-t xx-top">
            	<spring:message code="personal"></spring:message>
        </div>
        <div class="xx-content">
            <div class="h85">
                <span class="con-title"><spring:message code="portrait"></spring:message></span>
                <span class="con-content tou-x"><img src="${pageContext.request.contextPath }/upload/${member.mImg}"></span>
                <span class="f-r font2 up-down"><spring:message code="redact"></spring:message><i class="fa fa-angle-double-down"></i></span>
                <div class="clr"></div>
            </div>
            <div class="bor1-top h150 hide">
                <span class="con-title"></span>
                <span class="con-content upload-head">&nbsp;
                <div class="upload-tou f-l"><img id="ImgPr" width="80" height="80" /></div>
                     <div class="f-l add-up">
                    <div class="add-tou" ><spring:message code="member.uploadImg"></spring:message></div>                   
                     <form  id="form8" enctype="multipart/form-data" action="javascript:void(0)">
                     <input type="hidden" id="mId" name="mId" value="${member.mId}" />
                    <input type="file" id="imageInput"  name="image" onpropertychange="show();"/>
                    <input type="button" onclick="submit2();" value="<spring:message code="member.confirmUpload"></spring:message>" class="up-btn"/>
                    </form> 
                    </div>
                </span>
                <div class="clr"></div>
            </div>
          <!--   -->
            <div class="bor1-top h85">
                <span class="con-title"><spring:message code="member.name"></spring:message></span>
                <span class="con-content">${member.mNickname}</span>
                <span class="f-r font2 up-down"><spring:message code="redact"></spring:message><i class="fa fa-angle-double-down"></i></span>
                <div class="clr"></div>
            </div>
            <div class="bor1-top h85 hide">
                <span class="con-title"></span>
                <span class="con-content">
                <form  id="nick"  action="javascript:void(0)">
                <input type="hidden" id="mId" name="mId" value="${member.mId}" />
                    <input type="text" name="nickname" id="nickname" onkeyup="this.value=this.value.replace(/\s/,'')" maxlength="11" autocomplete="off" class="input-modify" placeholder="<spring:message code="member.fileName"></spring:message>" />
                    <input type="button" onclick="nicknameSubmit();" value="<spring:message code="member.confirmChange"></spring:message>" class="btn-red"/>
                    </form>
                </span>
                <div class="clr"></div>
            </div>
            <div class="bor1-top h85">
                <span class="con-title"><spring:message code="member.contact"></spring:message>
                </span>
                <span class="con-content">${member.mFixedTelephone }</span>
                <span class="f-r font2 up-down"><spring:message code="redact"></spring:message><i class="fa fa-angle-double-down"></i></span>
                <div class="clr"></div>
            </div>
            <div class="bor1-top h85 hide">
                <span class="con-title"></span>
                <span class="con-content">
                 <form  id="mFixed"  action="javascript:void(0)">
                 <input type="hidden" id="mId" name="mId" value="${member.mId}" />
                    <input type="text" id="mFixedTelephone" name="mFixedTelephone" maxlength="11" autocomplete="off" class="input-modify" placeholder="<spring:message code="member.fileContact"></spring:message>" />
                    <input type="button" value="<spring:message code="member.confirmChange"></spring:message>" onclick="mFixedTelephoneSubmit();" class="btn-red"/>
                    </form>
                </span>
                <div class="clr"></div>
            </div>
            <div class="bor1-top h85">
                <span class="con-title"><spring:message code="member.phone"></spring:message></span>
                <span class="con-content">${member.mPhone }</span>
                <div class="clr"></div>
            </div>
            <div class="bor1-top h85">
                <span class="con-title"><spring:message code="member.email"></spring:message></span>
                <span class="con-content">${member.mEmail }</span>
                <span class="f-r font2 up-down"><spring:message code="redact"></spring:message><i class="fa fa-angle-double-down"></i></span>
                <div class="clr"></div>
            </div>
            <div class="bor1-top h85 hide">
                <span class="con-title"></span>
                <span class="con-content">
                <form id="form5" action="javascript:void(0)">
                <input type="hidden" id="mId" name="mId"  value="${member.mId}" />
                    <input type="text" name="email" id="email" class="input-modify" autocomplete="off" placeholder="<spring:message code="member.fileEmail"></spring:message>" style="ime-mode:disabled"/>
                    <input type="button" value="<spring:message code="member.confirmChange"></spring:message>" onclick="submit7();" class="btn-red"/>
                    </form>
                </span>
                <div class="clr"></div>
            </div>
            <div class="bor1-top h85">
                <span class="con-title"><spring:message code="member.address"></spring:message></span>
                <span class="con-content">${address }</span>
                <span class="f-r font2 up-down"><spring:message code="redact"></spring:message><i class="fa fa-angle-double-down"></i></span>
                <div class="clr"></div>
            </div> 
            <!-- 下面是添加的内容 -->
            <div class="bor1-top h85 hide">
            <form id="formDomain" action="javascript:void(0)">
            	<input type="hidden" name="domain" value="1">
            	<input type="hidden" id="mId" name="mId"  value="${member.mId}" />
            	<div class="form-group">
                    <label class="w-200 f-l pr-15 pl-15 control-label con-title"><spring:message code="member.info.province"></spring:message>：</label>
                    <div class="w-350 f-l">
                         <select class="form-control form-control-select m-b" id="province" name="province" onchange="getDomain(this)">
                         	<option value="">--请选择--</option>
                         	<c:forEach items="${provinceList }" var="province">
                         		<option value="${province.dCode }" <c:if test="${province.dCode==member.mProvince }">selected="selected"</c:if>>${province.dName }</option>
                         	</c:forEach>
                         </select>
                     </div>
                </div>
                <div class="form-group">
                    <label class="w-200 f-l pr-15 pl-15 control-label con-title"><spring:message code="member.info.city"></spring:message>：</label>
                    <div class="w-350 f-l">
                         <select class="form-control form-control-select m-b" id="city" name="city" onchange="getDomain(this)">
                         	<c:if test="${not empty member.mProvince }">
	                         	<c:forEach items="${cList }" var="city">
	                         		<option value="${city.dCode }" <c:if test="${city.dCode==member.mCity }">selected="selected"</c:if>>${city.dName }</option>
	                         	</c:forEach>
                         	</c:if>
                         </select>
                     </div>
                </div>
                <div class="form-group">
                    <label class="w-200 f-l pr-15 pl-15 control-label con-title"><spring:message code="member.info.area"></spring:message>：</label>
                    <div class="w-350 f-l">
                         <select class="form-control form-control-select m-b" id="area" name="area">
	                         <c:if test="${not empty member.mCity }">
	                         	<c:forEach items="${aList }" var="area">
	                         		<option value="${area.dCode }" <c:if test="${area.dCode==member.mArea }">selected="selected"</c:if>>${area.dName }</option>
	                         	</c:forEach>
                         	 </c:if>
                         </select>
                     </div>
                </div>
            </form>
            &nbsp;&nbsp;&nbsp;&nbsp;
            <input type="button" value="<spring:message code="member.confirmChange"></spring:message>" onclick="addressSubmit()" class="btn-red"/>
            </div>
                <!-- 上面是添加的内容 -->
            <div class="bor1-top h85 hide">
                <span class="con-title"></span>
                <span class="con-content">
                <form id="form4" action="javascript:void(0)">
                <input type="hidden" id="mId" name="mId" value="${member.mId}" />
                    <input type="text" name="adress" id="adress" maxlength="27" class="input-modify" autocomplete="off" placeholder="<spring:message code="member.fileAddress"></spring:message>" />
                    <input type="button" value="<spring:message code="member.confirmChange"></spring:message>" onclick="addressSubmit();" class="btn-red"/>
                    </form>
                </span>
                <div class="clr"></div>
            </div>
        </div>
    </div>
<!--用户中心 end-->
<!--全局-->
<script type="text/javascript" src="${pageContext.request.contextPath }/web/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/web/js/public.js"></script>
<!--ie789下placeholder不兼容-->
<script type="text/javascript" src="${pageContext.request.contextPath }/web/js/placeholder.js"></script>
<!--头部的以图搜图-->
<%-- <script type="text/javascript" src="${pageContext.request.contextPath }/web/js/uppicFile.js"></script> --%>
<!--用户中心-->
<%-- <script type="text/javascript" src="${pageContext.request.contextPath }/web/js/subpage/person.js"></script> --%>

<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/layer/2.1/layer.js"></script>
<!--异步提交表单  -->
<script type="text/javascript" src="${pageContext.request.contextPath }/web/js/jquery-form.js"></script>
<!-- 上传图片的JS -->
<script type="text/javascript" src="${pageContext.request.contextPath }/web/js/uploadpreview.js"></script>
<script type="text/javascript">

var str1 = '<spring:message code="redact"></spring:message><i class="fa fa-angle-double-down"></i>';
var str2 = '<spring:message code="member.packUp"></spring:message><i class="fa fa-angle-double-up"></i>';
//右侧“收起”、“编辑”
$(".up-down").unbind().click(function () {
    if ($(this).html() == str1) {
        $(this).html(str2);
        $(this).parent().next().removeClass("hide");
    } else {
        $(this).html(str1);
        $(this).parent().next().addClass("hide");
    }
});


	$(function () {
		//初始化行政区划数据
	 	//initDomain();
        $("#imageInput").uploadPreview({ Img: "ImgPr", Width: 120, Height: 120 });
    });
function submit2(){
	if($("#imageInput").val()==""){
		layer.msg("<spring:message code="member.uploadImg"></spring:message>！",{icon:0,time:1000});
		return false;
	}
	$('#form8').ajaxSubmit({
		type:"POST",
		url:"${pageContext.request.contextPath }/member/member/accountManage",
		success:function(data){
			if(data==1){
				layer.msg("<spring:message code="member.sucUpdate"></spring:message>！",{icon:1,time:1000},function(){
					top.location.href="${pageContext.request.contextPath }/member/member/memberInfomation-0/index";
				});
			}else{
				layer.msg("<spring:message code="member.failUpdate"></spring:message>！",{icon:0,time:1000});
			}
		}
	});
}

function nicknameSubmit(){ 
	var nickname=$("#nickname").val();	
	if(nickname == ""){
		 layer.msg("<spring:message code="member.fileName"></spring:message>！",{icon:0,time:1000});
		 return false;
	}
			$('#nick').ajaxSubmit({
				type:"POST",
				url:"${pageContext.request.contextPath }/member/member/accountManage",
				success:function(data){
					if(data==1){
						layer.msg("<spring:message code="member.sucUpdate"></spring:message>！",{icon:1,time:1000},function(){
							top.location.href="${pageContext.request.contextPath }/member/member/memberInfomation-0/index";
						});
					}else{
						layer.msg("<spring:message code="member.failUpdate"></spring:message>！",{icon:0,time:1000});
					}
    			}
			});
	
}

function mFixedTelephoneSubmit(){ 
	var mFixedTelephone=$("#mFixedTelephone").val();	
	if(mFixedTelephone == ""){
		 layer.msg("<spring:message code="member.fileContact"></spring:message>！",{icon:0,time:1000});
		 return false;
	}
			$('#mFixed').ajaxSubmit({
				type:"POST",
				url:"${pageContext.request.contextPath }/member/member/accountManage",
				success:function(data){
					if(data==1){
						layer.msg("<spring:message code="member.sucUpdate"></spring:message>！",{icon:1,time:1000},function(){
							top.location.href="${pageContext.request.contextPath }/member/member/memberInfomation-0/index";
						});
					}else{
						layer.msg("<spring:message code="member.failUpdate"></spring:message>！",{icon:0,time:1000});
					}
    			}
			});
	
}

function submit7(){
	   var email=$("#email").val(); 
 	reg=/^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/gi;
 	if(email != ''){          	
 	if(!reg.test(email)){
  		 layer.msg("<spring:message code="member.fileEmailValid"></spring:message>！",{icon:0,time:1000});
	   			  return false;
  	}
 	}
 	if(email == ''){
 		layer.msg("<spring:message code="member.fileEmail"></spring:message>！",{icon:0,time:1000});
 		return false;
 	}
	   $('#form5').ajaxSubmit({
			type:"POST",
			url:"${pageContext.request.contextPath }/member/member/accountManage",
			success:function(data){
				if(data==1){
					layer.msg("<spring:message code="member.sucUpdate"></spring:message>！",{icon:1,time:1000},function(){
						top.location.href="${pageContext.request.contextPath }/member/member/memberInfomation-0/index";
					});
				}else{
					layer.msg("<spring:message code="member.failUpdate"></spring:message>！",{icon:0,time:1000});
				}
		} 
});
}
/**
 * 提交省市县信息
 author by 张天敏
 */
function addressSubmit(){
	//地区拦截器
	var flags=domainInterceptors();
	//弹窗会话
	var flagBoolean=alertsMessage(flags);
	//如果正确就执行，如果不正确就不执行
	if(flagBoolean){
		$('#formDomain').ajaxSubmit({
			type:"POST",
			url:"${pageContext.request.contextPath }/member/member/accountManage",
			success:function(data){
				if(data==1){
					layer.msg("<spring:message code="member.sucUpdate"></spring:message>！",{icon:1,time:1000},function(){
						top.location.href="${pageContext.request.contextPath }/member/member/memberInfomation-0/index";
					});
				}else{
					layer.msg("<spring:message code="member.failUpdate"></spring:message>！",{icon:0,time:1000});
				}
			}
		});
		
	}
	
}

//-------------------------------------------下面是省市区三级联动-------------------------------------------------------------------------
		
		function getDomain(obj){
			var flag='';
			if(obj.id=='province'){
				flag='city';
			}else if(obj.id=='city'){
				flag='area';
			}
    		$.ajax({
    			async:false,
    			type:"post",
    			data:{"pId":obj.value},
    			url:"${pageContext.request.contextPath }/member/member/domainList",
    			success:function(result){
    				var status=result.msg.status;
    				if(status==0){
    					var domainList=result.data.domainList;
    					$("#"+flag).empty();
    					var domain="<option value=''>--请选择--</option>";
    					for(var i=0;i<domainList.length;i++){
    						domain+='<option value="'+domainList[i].dCode+'">'+domainList[i].dName+'</option>'
    					}
    					$("#"+flag).append(domain);
    				}else if(status==1){
    					
    				}
    			}
    		});
		}
		
		/**
		* 地区拦截器
		* @author By 张天敏
		*/
		function domainInterceptors(){
			var provinceFlag=false;
			var cityFlag=false;
			var areaFlag=false;
			var provinceVal=$('#province').val();
			var cityVal=$('#city').val();
			var areaVal=$('#area').val();
			var flags={};
			//省拦截器
			if(provinceVal>0&&provinceVal<1000000){
				provinceFlag=true;
			}
			//市拦截器
			if(cityVal>0&&cityVal<1000000){
				cityFlag=true;
			}
			//区/县拦截器
			if(areaVal>0&&areaVal<1000000){
				areaFlag=true;
			}
			
			flags.provinceFlag=provinceFlag;
			flags.cityFlag=cityFlag;
			flags.areaFlag=areaFlag;
			return flags;
			
		}
		
		/**
		* 拦截器弹窗
		* author by 张天敏
		*/
		function alertsMessage(flags){
			var flagBoolean=false;
			if(flags.provinceFlag){
				flagBoolean=true;
			}else{
				layer.msg("<spring:message code="member.chooseProvince"></spring:message>！",{icon:0,time:1000});
				return flagBoolean=false;
			}
			if(flags.cityFlag){
				flagBoolean=true;
			}else{
				layer.msg("<spring:message code="member.chooseCity"></spring:message>！",{icon:0,time:1000});
				return flagBoolean=false;
			}
			if(flags.areaFlag){
				flagBoolean=true;
			}else{
				layer.msg("<spring:message code="member.chooseArea"></spring:message>！",{icon:0,time:1000});
				return flagBoolean=false;
			}
			return flagBoolean;
		}
		


</script>
</body>
</html>